home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / COMMAND.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  5KB  |  159 lines

  1. ;*****************************;
  2. ; SESSION Input and Messaging ;
  3. ;        By Eric Tauck        ;
  4. ;*****************************;
  5.  
  6. c_lev   DB      0                       ;command window nest level
  7.  
  8. ;========================================
  9. ; Open the command line.
  10.  
  11. Command_Open    PROC    NEAR
  12.  
  13. ;--- save display state if first level
  14.  
  15.         cmp     c_lev, 0        ;check if first open
  16.         jne     cmdopn1         ;jump if so
  17.  
  18.         call    CurPos          ;get cursor position
  19.         mov     c_sav1, ax      ;save location
  20.         call    CurGet          ;get cursor state
  21.         mov     c_sav2, al      ;save state
  22.  
  23.         sub     bx, bx          ;upper left
  24.         sub     ch, ch          ;row zero
  25.         mov     cl, cols        ;columns
  26.         dec     cl
  27.         push    bx
  28.         push    cx
  29.         call    ScrSiz          ;get bytes needed
  30.         call    MemAll          ;allocate memory (assume success)
  31.         pop     cx
  32.         pop     bx
  33.         mov     s_sav, ax       ;save segment
  34.         mov     s_loc1, bx      ;save upper left
  35.         mov     s_loc2, cx      ;save lower right
  36.         mov     dx, ax
  37.         sub     ax, ax
  38.         call    ScrGet          ;copy screen to memory
  39.  
  40. ;--- finished
  41.  
  42. cmdopn1 sub     al, al          ;zero flag
  43.         call    CurSet          ;turn cursor off
  44.         sub     ax, ax          ;upper left corner
  45.         call    CurMov          ;position cursor
  46.  
  47.         inc     c_lev           ;increment level
  48.         ret
  49.         ENDP
  50.  
  51. ;========================================
  52. ; Close the command line.
  53.  
  54. Command_Close   PROC    NEAR
  55.         dec     c_lev           ;decrement level
  56.         cmp     c_lev, 0        ;check if level zero
  57.         jne     cmdclo1         ;jump if not
  58.  
  59.         mov     bx, s_loc1      ;upper left
  60.         mov     cx, s_loc2      ;lower right
  61.         mov     dx, s_sav       ;load segment
  62.         sub     ax, ax          ;offset zero
  63.         call    ScrPut          ;restore screen
  64.         mov     ax, s_sav       ;memory segment
  65.         call    MemRel          ;release memory
  66.  
  67.         mov     ax, c_sav1      ;saved location
  68.         call    CurMov          ;position cursor
  69.         mov     al, c_sav2      ;saved state
  70.         call    CurSet          ;set state
  71.  
  72. cmdclo1 ret
  73.         ENDP
  74.  
  75. ;========================================
  76. ; Display a status line.
  77. ;
  78. ; In: AX= prompt address.
  79.  
  80. Command_Status  PROC    NEAR
  81.         push    ax
  82.         mov     al, attr_stat   ;status color
  83.         call    AtrSet          ;set attribute
  84.         sub     ax, ax          ;upper left corner
  85.         call    CurMov          ;position cursor
  86.         pop     ax              ;restore prompt address
  87.         mov     cl, cols        ;width
  88.         call    ProWrt          ;display
  89.         ret
  90.         ENDP
  91.  
  92. ;========================================
  93. ; Display an error message.
  94. ;
  95. ; In: AX= error message.
  96.  
  97. Command_Error PROC    NEAR
  98.         push    ax
  99.         call    Command_Open    ;open command line
  100.         mov     al, attr_error  ;color
  101.         call    AtrSet          ;set attribute
  102.         call    Beep_Error      ;error beep
  103.         pop     ax
  104.         mov     cl, cols
  105.         call    InpEsc          ;display prompt and wait for ESC
  106.         call    Command_Close   ;close window
  107.         ret
  108.         ENDP
  109.  
  110. ;========================================
  111. ; Confirm an operation.
  112. ;
  113. ; In: AX= prompt address.
  114. ;
  115. ; Out: CY= set if abort ('N' or ESC).
  116.  
  117. Command_Confirm PROC    NEAR
  118.         push    ax
  119.         call    Command_Open    ;open command line
  120.         mov     al, attr_conf   ;status color
  121.         call    AtrSet          ;set attribute
  122.         pop     ax
  123.         mov     cl, cols
  124.         call    InpVer          ;verify
  125.         lahf
  126.         push    ax
  127.         call    Command_Close   ;close window
  128.         pop     ax
  129.         sahf
  130.         ret
  131.         ENDP
  132.  
  133. ;========================================
  134. ; Input a string.
  135. ;
  136. ; In: AX= prompt address; BX= input
  137. ;     buffer.
  138. ;
  139. ; Out: CY= set if cancel input.
  140.  
  141. Command_Input   PROC    NEAR
  142.         push    ax
  143.         push    bx
  144.         call    Command_Open    ;open command line
  145.         mov     al, attr_inp1   ;prompt color
  146.         call    AtrSet          ;set attribute
  147.         pop     bx
  148.         pop     ax
  149.  
  150.         mov     cl, cols
  151.         call    InpStr          ;input string
  152.         lahf
  153.         push    ax
  154.         call    Command_Close   ;close window
  155.         pop     ax
  156.         sahf
  157.         ret
  158.         ENDP
  159.